$(document).ready(function () {
    // 基于准备好的dom，初始化echarts实例
    var finance_sta = echarts.init(document.getElementById('finance_sta'));
    var credit_line = echarts.init(document.getElementById('credit_line'));


    // 融资申请统计图表的配置项和数据
    finance_sta_option = {
        color: ['#3398DB'],
        tooltip: {
            trigger: 'axis',
            axisPointer: {// 坐标轴指示器，坐标轴触发有效
                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
            {
                type: 'category',
                data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
                axisTick: {
                    alignWithLabel: true
                }
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: [
            {
                name: '融资申请数',
                type: 'bar',
                barWidth: '60%',
                data: [10, 52, 200, 334, 390, 330, 220]
            }
        ]
    };

    credit_line_option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                }
            }
        },
        grid: {// 控制图的大小，调整下面这些值就可以，
            x: 80,

        },
        legend: {
            //data: ['蒸发量', '降水量', '平均温度']
        },
        xAxis: [
            {
                type: 'category',
                //data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '融资金额',
                min: 0,
                //max: 500,
                interval: 100,
                axisLabel: {
                    formatter: '{value} 万元',

                }
            }
        ],
        series: [
            {
                name: '金额',
                type: 'bar',
                //data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
            },
            {
                name: '笔数',
                type: 'bar',
                // data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
            },
        ]
    };




    // 制定置项和数据显示图表。
    $.get($('#financeecharts').val()).done(function (data) {
        finance_sta_option.series[0].data = data.arr[0].data;
        finance_sta_option.series[0].name = data.arr[0].name;
        finance_sta_option.xAxis[0].data = data.time;
        finance_sta.setOption(finance_sta_option);
    });

    $.get($('#financequotacharts').val()).done(function (data) {

        finance_sta_option.series[0].data = data.arr[0].data;
        finance_sta_option.series[0].name = data.arr[0].name;
        finance_sta_option.xAxis[0].data = data.time;
        credit_line.setOption(finance_sta_option);

//        credit_line_option.xAxis[0].data = data.title;
//        credit_line_option.yAxis[0].max = data.max;
//        interval = data.max;
//        if (data.max > 10)
//        {
//            interval = parseInt(data.max / 10);
//        }
//        credit_line_option.yAxis[0].interval = interval;
//        credit_line_option.series[0].data = data.quota;
//        credit_line_option.series[1].data = data.count;
//        credit_line.setOption(credit_line_option);
    });

    $(".nav li").mouseenter(function () {
        if ($(this).has("ul").length) {
            $(this).children("ul").show();
            $(this).addClass('current');
        }
    }).mouseleave(function () {
        if ($(this).has("ul").length) {
            $(this).children("ul").hide();
            $(this).removeClass('current');
        }
    });
})